import { defineStore } from 'pinia'
import { getSearchRequest } from '@/service/module/search/search'

interface Isearchdemo {
  _id: number
  iid: number
  title: string
  paper: string
  image: string
  path: string
  name: string
  content: string
  question: string
}

export const useSearchStore = defineStore('search', {
  state: () => ({
    searchdemo: [] as Isearchdemo[],
    total: 0,
    iid: 0,
    name: '',
  }),

  actions: {
    async searchResultAction(keyword: string) {
      //实验  getAdminRequest

      const res = await getSearchRequest(keyword)
      // console.log(res, '所搜的数据')

      this.searchdemo = res.data.data.searchAdminListData

      // this.total = res.data.data.total
      // this.iid = res.data.data[0].iid
      console.log(this.searchdemo, '444444')
    },
  },
  // persist: true,
})
